import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { AnswersVO, AnswersForm, AnswersQuery } from '@/api/answer/answers/types';

/**
 * 查询统一答案列表
 * @param query
 * @returns {*}
 */

export const listAnswers = (query?: AnswersQuery): AxiosPromise<AnswersVO[]> => {
  return request({
    url: '/answer/answers/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询统一答案详细
 * @param answerId
 */
export const getAnswers = (answerId: string | number): AxiosPromise<AnswersVO> => {
  return request({
    url: '/answer/answers/' + answerId,
    method: 'get'
  });
};

/**
 * 新增统一答案
 * @param data
 */
export const addAnswers = (data: AnswersForm) => {
  return request({
    url: '/answer/answers',
    method: 'post',
    data: data
  });
};

/**
 * 修改统一答案
 * @param data
 */
export const updateAnswers = (data: AnswersForm) => {
  return request({
    url: '/answer/answers',
    method: 'put',
    data: data
  });
};

/**
 * 删除统一答案
 * @param answerId
 */
export const delAnswers = (answerId: string | number | Array<string | number>) => {
  return request({
    url: '/answer/answers/' + answerId,
    method: 'delete'
  });
};
